package com.gitee.feizns.explore.data_structure.tree.bs.easy;

/**
 * @author feizns
 * @since 2020/1/4
 */
public class NTreeMaxDepth {

    public static void main(String[] args) {

    }

    public static int maxDepth(Node root) {
        if ( root != null ) {
            if ( root.children == null || root.children.isEmpty() )
                return 1;
            int max = maxDepth(root.children.get(0));
            for (int i = 1; i < root.children.size(); i++) {
                int depth = maxDepth(root.children.get(i));
                if ( depth > max )
                    max = depth;
            }
            return max + 1;
        }
        return 0;
    }

}
